package qdu.rg012.ch4_sqlite;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

public class Go_sqlite extends Activity {
    My_dbadptor mydbadp;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.go_sqlite);

        findViewById(R.id.btn_create_db).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mydbadp = new My_dbadptor(Go_sqlite.this);


            }
        });

        findViewById(R.id.btn_getall).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(mydbadp != null) {
                    mydbadp.opendb();
                    String tmp= "";
                    tmp = mydbadp.getall();
                    if(!"".equals(tmp))
                        ((TextView)findViewById(R.id.tv_show_info)).setText(
                            "查全表: " + tmp);
                    else
                        ((TextView)findViewById(R.id.tv_show_info)).setText("空表");


                    mydbadp.closedb();
                }
            }
        });
    }
}
